package com.toycloud.business.controller.business;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.toycloud.business.dto.params.business.FeedbackProductVersionManagerParams;
import com.toycloud.business.dto.results.CommonResult;
import com.toycloud.common.core.controller.BaseController;
import com.toycloud.common.core.utils.poi.ExcelUtil;
import com.toycloud.common.core.web.domain.AjaxResult;
import com.toycloud.system.domain.business.FeedbackProductVersionManager;
import com.toycloud.system.log.annotation.Log;
import com.toycloud.system.log.enums.BusinessType;
import com.toycloud.system.mapper.business.FeedbackProductVersionManagerMapper;
import com.toycloud.system.service.business.IFeedbackProductVersionManagerDetailService;
import com.toycloud.system.service.business.IFeedbackProductVersionManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 产品版本管理Controller
 * 
 * @author ruoyi
 * @date 2024-12-18
 */
@RestController
@RequestMapping("/versionmanager")
public class FeedbackProductVersionManagerController extends BaseController
{
    @Autowired
    private IFeedbackProductVersionManagerService feedbackProductVersionManagerService;
    @Resource
    private FeedbackProductVersionManagerMapper feedbackProductVersionManagerMapper;
    @Autowired
    private IFeedbackProductVersionManagerDetailService feedbackProductVersionManagerDetailService;

    /**
     * 查询产品版本管理列表
     */
    @GetMapping("/page")
    public CommonResult<List<FeedbackProductVersionManager>> list(FeedbackProductVersionManagerParams feedbackProductVersionManagerParams)
    {
        return feedbackProductVersionManagerService.selectFeedbackProductVersionManagerList(feedbackProductVersionManagerParams);
    }

    /**
     * 导出产品版本管理列表
     */
    @Log(title = "产品版本管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,@RequestBody FeedbackProductVersionManagerParams feedbackProductVersionManagerParams)
    {
        CommonResult<List<FeedbackProductVersionManager>> list = feedbackProductVersionManagerService.export(feedbackProductVersionManagerParams);
        ExcelUtil<FeedbackProductVersionManager> util = new ExcelUtil<FeedbackProductVersionManager>(FeedbackProductVersionManager.class);
        util.exportExcel(response, list.getData(), "产品版本管理数据");
    }
/**
 * @Auther: doubaolin
 * @Date: 2024/12/19 10:13
 * @Description: 产品品牌下拉
 * @param
 * @return:
 */
    @GetMapping("/selectProductBrandOption")
    public AjaxResult selectProductBrandOption()
    {
        return AjaxResult.success(feedbackProductVersionManagerService.selectProductBrandOption());
    }

/**
 * @Auther: doubaolin
 * @Date: 2024/12/19 10:15
 * @Description: 产品品类下拉
 * @param
 * @return:
 */
    @GetMapping("/selectProductTypeOption")
    public AjaxResult selectProductTypeOption()
    {
        return AjaxResult.success(feedbackProductVersionManagerService.selectProductTypeOption());
    }
    /**
     * @Auther: doubaolin
     * @Date: 2025/2/12 11:28
     * @Description: 三级参数下拉
     * @param
     * @return:
     */
    @GetMapping("/selectThreeParamOption")
    public AjaxResult selectThreeParamOption(@RequestParam String id)
    {
        return AjaxResult.success(feedbackProductVersionManagerService.selectThreeParamOption(id));
    }

/**
 * @Auther: doubaolin
 * @Date: 2024/12/19 10:15
 * @Description: 产品型号下拉
 * @param
 * @return:
 */
    @GetMapping("/selectProductModelOption")
    public AjaxResult selectProductModelOption(@RequestParam(value = "id", required = false)String id,@RequestParam(value = "type", required = false)String type)
    {
        return AjaxResult.success(feedbackProductVersionManagerService.selectProductModelOption(id,type));
    }

    @PostMapping("/add")
    public CommonResult add(@Valid @RequestBody FeedbackProductVersionManager feedbackApplicationVersionManager)
    {
        return feedbackProductVersionManagerService.insertFeedbackProductVersionManager(feedbackApplicationVersionManager);
    }

    @PostMapping("/update")
    public CommonResult update(@Valid @RequestBody FeedbackProductVersionManager feedbackApplicationVersionManager)
    {
        return feedbackProductVersionManagerService.updateFeedbackProductVersionManager(feedbackApplicationVersionManager);
    }

    @GetMapping("/{id}")
    public AjaxResult getProductVersion(@PathVariable String id)
    {
        return AjaxResult.success(feedbackProductVersionManagerService.selectFeedbackProductVersionManagerById(id));
    }

    @PostMapping("/delete/{id}")
    public AjaxResult delete(@PathVariable String id)
    {
        feedbackProductVersionManagerService.deleteFeedbackProductVersionManagerById(id);
        feedbackProductVersionManagerDetailService.deleteFeedbackProductVersionManagerDetailByParentid(id);
        return AjaxResult.success("删除成功");
    }

}
